﻿using SilverChart.Core.Configuration;
using SilverChart.Core.Service;

namespace SilverChart.Configuration.Converter {
    [ServiceProvider(LayzeCreation = true, ServiceName = "Default LegendDirection configuration converter", Singleton = true)]
    public class LegendDirectionConverter : ConfigurationConverter<LegendDirection> {

        public bool Convert(string input, out LegendDirection value) {
            switch (input.ToLower()) {
                case "horizontal":
                case "h":
                    value = LegendDirection.Horizontal;
                    break;
                case "vertical":
                case "v":
                    value = LegendDirection.Vertical;
                    break;
                default:
                    value = LegendDirection.Unkonwn;
                    return false;
            }
            return true;
        }
    }
}
